package com.flower.service.impl;

import com.flower.dao.DitailedMapper;
import com.flower.dao.ShoppingMapper;
import com.flower.pojo.Ditailed;
import com.flower.service.DitailedService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Isolation;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;
import java.util.Map;

@Service
public class DitailedServiceImpl implements DitailedService {
    @Autowired
    private DitailedMapper ditailedMapper;
    @Autowired
    private ShoppingMapper shoppingMapper;

    @Override
    @Transactional(readOnly = false,isolation = Isolation.DEFAULT,propagation = Propagation.REQUIRED)
    public int addDitailed(List<Ditailed> list) throws Exception{
        int result=-1;
        if(ditailedMapper.addDitailed(list)!=-1&&shoppingMapper.clearShopping()!=-1){
            result=1;
        }else {
            throw new Exception() ;
        }
        return result;
    }

    @Override
    public List<Map<String, Object>> queryDitailed(Integer oid) {
        return ditailedMapper.queryDitailed(oid);
    }
}
